#include <vector>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <stack>
#include <climits>

using namespace std;

int pos[105][105];
int dp[105][105];
int n;

void print(const string &s, string &ans, int i, int j)
{
    if (i > j)
        return;
    if (i == j)
    {
        if (s[i] == '(' || s[i] == ')')
            ans += "()";
        else
            ans += "[]";
    }
    else if (pos[i][j] == -1)
    {
        ans += string(1, s[i]);
        print(s, ans, i + 1, j - 1);
        ans += string(1, s[j]);
    }
    else
    {
        print(s, ans, i, pos[i][j]);
        print(s, ans, pos[i][j] + 1, j);
    }
}

bool match(const char &a, const char &b)
{
    if (a == '(' && b == ')')
        return true;
    if (a == '[' && b == ']')
        return true;
    return false;
}
int main()
{
    memset(dp, 0, sizeof(dp));
    memset(pos, -1, sizeof(pos));
    string s;
    cin >> s;
    int n = s.size();
    for (int i = 0; i < n; i++)
        dp[i][i] = 1;
    for (int len = 1; len < n; len++)
        for (int i = 0; i + len < n; i++)
        {
            int j = i + len;
            dp[i][j] = INT_MAX;
            if (match(s[i], s[j]))
            {
                dp[i][j] = dp[i + 1][j - 1];
                pos[i][j] = -1;
            }
            for (int k = i; k < j; k++)
            {
                if (dp[i][j] > dp[i][k] + dp[k + 1][j])
                {
                    dp[i][j] = dp[i][k] + dp[k + 1][j];
                    pos[i][j] = k;
                }
            }
        }
    string ans;
    print(s, ans, 0, n - 1);
    cout << ans <<endl;

    return 0;
}
